﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using CoreRay.Testing.MockClasses;

namespace CoreRay.Testing
{
    //-----------------------------------------------------------------------------------------
    /// <summary>
    /// This is a test class for SamplerTest and is intended to contain all SamplerTest 
    /// Unit Tests.
    /// </summary>
    //-----------------------------------------------------------------------------------------
    [TestClass]
    public class SamplerTest
    {
        //-----------------------------------------------------------------------------------------
        /// <summary>
        /// A test for <see cref="Sampler"/> constructor.
        /// </summary>
        //-----------------------------------------------------------------------------------------
        [TestMethod]
        public void SamplerConstructorTest()
        {
            RenderRegion renderRegion = new RenderRegion(20, 30, 750, 345);
            int samplesPerPixel = 2;

            Sampler target = new MockSampler(renderRegion, samplesPerPixel);

            Assert.IsTrue(target.RenderRegion == renderRegion && target.SamplesPerPixel == samplesPerPixel);
        }


        //-----------------------------------------------------------------------------------------
        /// <summary>
        /// A test for TotalSamples.
        /// </summary>
        //-----------------------------------------------------------------------------------------
        [TestMethod]
        public void TotalSamplesTest()
        {
            RenderRegion renderRegion = new RenderRegion(20, 30, 750, 345);
            int samplesPerPixel = 2;

            Sampler target = new MockSampler(renderRegion, samplesPerPixel);

            int expected = samplesPerPixel * (renderRegion.Width - renderRegion.PositionX) * (renderRegion.Height - renderRegion.PositionY);
            int actual = target.TotalSamples;

            Assert.AreEqual(expected, actual);
        }


        //-----------------------------------------------------------------------------------------
        /// <summary>
        /// A test for GenerateSamples.
        /// </summary>
        //-----------------------------------------------------------------------------------------
        [TestMethod]
        public void GenerateSamplesTest()
        {
            RenderRegion renderRegion = new RenderRegion(20, 30, 750, 345);
            int samplesPerPixel = 2;

            Sampler target = new MockSampler(renderRegion, samplesPerPixel);

            int expected = 5;
            int actual = 0;

            foreach(Sample sample in target.GenerateSamples())
            {
                actual++;
            }

            Assert.AreEqual(expected, actual);
        }
    }
}
